import React from 'react';

export default class Clock extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            mDate : new Date()
        }
    }


    componentDidMount(){
        this.TimeID = setInterval(this.thick,1000)
    }

    componentWillUnmount(){
        clearInterval(this.TimeID);
    }

    thick = ()=>{
       this.setState({
           mDate:new Date()
       });
    }

    render(){
        return (
            <div>
                <h1>this is a clock</h1>
                <p>now is {this.state.mDate.toLocaleTimeString()}</p>
            </div>
        );
    }

    

}
